import Redis from "ioredis";
import { redisConfig } from "../config/config.default.js";

const redis = new Redis({
  port: redisConfig.port,
  host: redisConfig.host,
  password: redisConfig.password,
  db: redisConfig.db,
});

redis.on("error", (err) => {
  if (err) {
    console.log("redis error", err);
    redis.quit();
  }
});

redis.on("ready", () => {
  console.log("redis success");
});

export default redis;
